package com.ray.friendslist.content;

import java.util.List;

import org.json.JSONObject;

import android.util.Log;

import com.ray.friendslist.content.task.ParamCallback;
import com.ray.friendslist.feeds.FeedEntyty;
import com.ray.friendslist.feeds.VkFeedsArray;
import com.ray.friendslist.friends.FriendsArray;
import com.ray.friendslist.token.VkTokenManager;
import com.ray.friendslist.wall.WallItemsArray;

public class ContentManager {

	private static ContentManager instance;

	public static ContentManager getInstance() {
		if (instance == null) {
			instance = new ContentManager();
		}
		return instance;
	}

	public void getVkFriends(
			final ParamCallback<List<JSONObject>> paramCallback,
			String apiRequestURL) {
		new FriendsArray(paramCallback).start(apiRequestURL);
	}

	public void getVkFeeds(final ParamCallback<List<JSONObject>> paramCallback) {
		String request = "https://api.vk.com/method/newsfeed.get?filters=post,from,offset&count=40"/*&offset="
				+ FeedEntyty.getFeedOffset()
				+ "&from="
				+ FeedEntyty.getFeedFrom()*/
				+ "&access_token="
				+ VkTokenManager.getTooken();
		new VkFeedsArray(paramCallback)
				.start(request);
		Log.i("ray", "REQUEST = " + request);
		
		Log.i("ray", "FROM = " + FeedEntyty.getFeedFrom());
		Log.i("ray", "OFFSET = " + FeedEntyty.getFeedOffset());
	}

	public void getVkWall(final ParamCallback<List<JSONObject>> paramCallback,
			String ownerID) {
		new WallItemsArray(paramCallback)
				.start("https://api.vk.com/method/wall.get?owner_id=" + ownerID
						+ "&count=50&extended=1&access_token="
						+ VkTokenManager.getTooken());
	}
}
